package test.excel;
import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author DengZhiYuan
 * @version 1.0
 * @date 2022/12/2 19:38
 */
public class ExcelMain {


    public static void main(String[] args) {
        // 写法1
        String fileName = "C:\\Users\\dzy\\Desktop\\禅道1492全能爱无忧\\全国三甲1890家医院清单-含分院.xlsx";
        String saveFile = "C:\\Users\\dzy\\Desktop\\禅道1492全能爱无忧\\hospital.txt";
        ExcelListener excelListener = new ExcelListener();
         EasyExcel.read(fileName, HospitalEntity.class,excelListener).sheet().doRead();
        List<String> collect = excelListener.getList().stream().map(e -> JSONUtil.toJsonStr(e)).collect(Collectors.toList());
        FileUtil.writeLines(collect, saveFile, "UTF-8");
    }




}
